<template>
<view class="all">
    <!-- 导航栏 -->
    <view class="top">
        <view style="display: flex;position: relative;">
            <view class="search">
                <input type="text" v-model="query.keyword" @input="doSearch" placeholder="搜索手机号/订单号/新人姓名" placeholder-style="color:#999;font-size:13px;" />
                <icon class="searchIcon" @click="getOrderList" type="search" size="26upx"></icon>
            </view>
            <button type="primary" size="mini" @click="showFilter">筛选</button>
        </view>
    </view>
    <view class="allOrder" v-if="listData.length>0">
        <view class="orderBox" v-for="(item, index) in listData" :key="index+'list'">
            <view class="image">
                <image src="@/static/orderImgs/changeOrder.png" mode="" v-if="item.process == 2"></image>
                <image src="@/static/orderImgs/returnOrder.png" mode="" v-if="item.process == -1"></image>
            </view>
            <view class="title">
                <text class="number">合同号:{{ item.contract_no }}</text>
                <text class="status">{{ item.order_type }}-{{ item.item_check_status }}</text>
            </view>
            <view class="info">
                <view class="con">
                    <text class="txt1">签约公司</text>
                    <text class="txt2">{{ item.company }}</text>
                </view>
                <view class="con">
                    <text class="txt1">订单类型</text>
                    <text class="txt2">{{ item.news_type }}</text>
                </view>
                <view class="con">
                    <text class="txt1">签约日期</text>
                    <text class="txt2">{{ item.sign_date }}</text>
                </view>
                <view class="con">
                    <text class="txt1">举办日期</text>
                    <text class="txt2">{{ item.event_date }}</text>
                </view>
                <view class="con">
                    <text class="txt1">酒店名称</text>
                    <text class="txt2">{{ item.hotel }}</text>
                </view>
                <view class="con">
                    <text class="txt1">合作模式</text>
                    <text class="txt2">{{ item.cooperation_mode }}</text>
                </view>
                <template v-if="item.category == 7 || item.category == 8">
                    <view class="con">
                        <text class="txt1">联系姓名</text>
                        <text class="txt2">{{ item.bridegroom }}</text>
                    </view>
                    <view class="con">
                        <text class="txt1">联系电话</text>
                        <text class="txt2">{{ item.bridegroom_mobile }}</text>
                    </view>
                </template>
                <template v-else>
                    <view class="con" v-if="item.bride">
                        <text class="txt1">新娘姓名</text>
                        <text class="txt2">{{ item.bride }}</text>
                    </view>
                    <view class="con" v-if="item.bride_mobile">
                        <text class="txt1">新娘电话</text>
                        <text class="txt2">{{ item.bride_mobile }}</text>
                    </view>
                    <view class="con"v-if="item.bridegroom">
                        <text class="txt1">新郎姓名</text>
                        <text class="txt2">{{ item.bridegroom }}</text>
                    </view>
                    <view class="con" v-if="item.bridegroom_mobile">
                        <text class="txt1">新郎电话</text>
                        <text class="txt2">{{ item.bridegroom_mobile }}</text>
                    </view>
                </template>
            </view>
            <view class="btns">
                <view class="sell">
                    销售：[{{item.username}}]
                </view>
                <view class="detail">
                    <text class="check" @click="lookDetailFn(item.id)">查看详情</text>
                    <text class="check" @click="viewAudit(item.id)">查看审核</text>
                </view>
            </view>
        </view>
    </view>
    <van-empty v-else description="暂无记录" />
    <searchDialog ref="searchDialog" :getQuery="query" @getOrderList="getOrderList" :pagination="pagination" :listData="listData"></searchDialog>
</view>
</template>

<script>
import timeSelector from '@/component/wing-time-selector/wing-time-selector.vue';
import request from '@/utils/request.js';
import navigation from '@/component/navigation.vue';
import titleFix from "@/utils/titleFix";
import dictionary from '@/utils/dictionary.js';
import searchDialog from './list/search/mySearch.vue';
import {
    orderQuery
} from './list/search/query.js';
export default {
    name: "my",
    mixins: [titleFix],
    components: {
        navigation,
        timeSelector,
        searchDialog
    },
    data() {
        return {
            query: Object.assign({}, orderQuery), // 搜索条件
            pagination: {
                page: 1,
                limit: 15,
                total: 0
            },
            user: '', //个人信息
            listData: [], //订单列表
            searchDrawer: false,
            timeout: null
        };
    },
    onLoad() {
        this.getOrderList({});
    },
    onReachBottom() {

        if ((this.pagination.limit * this.pagination.page) <= this.pagination.total) {
            ++this.pagination.page;
            this.getOrderList();
        }

    },
    beforeMount() {
        this.dictionary = dictionary;
    },
    watch: {

    },
    methods: {
        getOrderList() {
            let that = this;
            let params = {};
            params = Object.assign({}, that.query);
            params['pagination'] = that.pagination;
            request.request({
                url: '/api/order.order/index',
                showLoading: true,
                token: true,
                data: params,
                success(res) {
                    if (res.code == 200) {
                        that.pagination = res.data.pagination;
                        console.log(that.pagination)
                        if (res.data.list.length > 0) {
                            that.listData = that.listData.concat(res.data.list);
                        }

                    }
                },
                fail(e) {
                    uni.showToast({
                        icon: 'none',
                        title: '服务器开小差去啦~'
                    });
                }
            });
        },
        //进入详情页
        lookDetailFn(id) {
            uni.navigateTo({
                url: '../order/detail/detail?order_id=' + id
            });
        },
        viewAudit(id) {
            uni.navigateTo({
                url: '../orderInfo/myApproval/myApproval?id=' + id
            });
        },
        doSearch() {
            let _this = this;
            _this.listData = [];
            if (_this.timeout) {
                clearTimeout(_this.timeout)
            }
            _this.timeout = setTimeout(function () {
                _this.pagination.page = 1;
                _this.getOrderList()
            }, 500)

        },
        //显示筛选框
        showFilter() {
            this.listData = [];
            this.$refs['searchDialog'].showDialogOpen()
        },
    }
};
</script>

<style lang="less" scoped>
page {

    background: #f4f4f4;
    padding-top: 0;

    /deep/ .uni-date-x--border {

        border: none !important;

    }

    /deep/ .uni-tag {
        font-weight: 500;
    }

    /deep/ .uni-drawer--right {
        -webkit-transform: translate3d(0, 0, 0);
        -moz-transform: translate3d(0, 0, 0);
        -ms-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }

    /deep/ .uni-date__x-input {
        height: 20px !important;
        padding: 0;
    }

    /deep/.uniui-calendar:before {
        display: none;
    }

    /deep/.uni-picker-container,
    .uni-list-item {
        font-size: 14px;
    }

    // /deep/.uni-list-item__container {
    //     overflow: inherit;
    // }

    /deep/ .uni-date-editor--x .uni-date__icon-clear {
        top: -8px;
        right: -15px;
    }

    /deep/.uni-input-input {
        line-height: 20px
    }
}

.btns {
    width: 100%;
    height: 36px;
    padding-left: 12px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    position: relative;

    .sell {
        flex: 1;
        font-size: 14px;
        white-space: nowrap;
        text-overflow: ellipsis;
        -o-text-overflow: ellipsis;
        overflow: hidden;
    }

    .detail {
        text-align: right;

        .check {
            border-radius: 10upx;
            border: #e1d9d9 solid 1upx;
            display: inline-block;
            padding: 0 6px;
            height: 50upx;
            font-size: 26upx;
            line-height: 50upx;
            text-align: center;
            color: #666666;
            margin-right: 12px;
        }
    }
}

.search_box {
    margin-bottom: 10px;
    background: white;
    padding-bottom: 10px;

    .item-footer {
        position: relative;
        text-align: right;
        display: block;
        width: 229px;
        font-size: 24upx;
        color: #666666;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;

        .tag {
            display: inline-block;
            padding: 1px 4px;
            position: relative;
            margin-right: 2px;

            ::after {
                content: '';
                width: 1px;
                height: 10px;
                background: #a08989;
                position: absolute;
                top: 4px;
                right: -2px
            }

            // .tag:after{
            //     width: 1px;
            //     height: 1px;
            //     background: red;
            //     position: absolute;
            //     right: 0;
            //     top:0
            // }
        }

        .clearIcon {
            position: absolute;
            right: -20px;
            top: 3px;
        }
    }

    .search_content {
        padding: 10px;

    }
}

.top {
    width: 100%;
    // height: 150upx;
    background: #ffffff;
    padding: 10upx 0 10upx 19upx;
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;

    .left {
        width: 50upx;
        height: 58upx;
        display: flex;
        align-items: center;
        float: left;

        image {
            width: 40upx;
            height: 40upx;
        }
    }

    .search {
        position: relative;
        width: 576upx;
        height: 58upx;
        margin-left: 10upx;
        float: left;

        input {
            width: 576upx;
            height: 58upx;
            background: rgba(255, 255, 255, 1);
            border: 1upx solid rgba(238, 238, 238, 1);
            border-radius: 10upx;
            padding-left: 1rem;
            box-sizing: border-box;
        }

        .searchIcon {
            position: absolute;
            right: 1rem;
            top: 50%;
            transform: translateY(-50%);
        }
    }

    .screen {
        width: 55upx;
        height: 58upx;
        font-size: 26upx;
        color: #406ceb;
        margin-left: 10upx;
        line-height: 58upx;
    }
}

/* 顶部tabbar */
.nav-bar {
    // position: fixed;
    // left: 0;
    // top:230upx;
    // z-index: 10;
    // height: 90upx;
    padding: 20upx 0;
    // line-height: 90upx;
    white-space: nowrap;
    box-shadow: 0 2upx 8upx rgba(0, 0, 0, 0.06);
    background-color: #fff;

    .uni-scroll-view-content {}

    .nav-item {
        display: inline-block;
        padding: 5px 20upx;
        text-align: center;
        font-size: 13px;
        color: #303133;
        position: relative;

        &:after {
            content: '';
            width: 0;
            height: 0;
            border-bottom: 4upx solid #007aff;
            position: absolute;
            left: 50%;
            bottom: 0;
            transform: translateX(-50%);
            transition: 0.3s;
        }
    }

    .current {
        color: #ffffff;
        background: rgba(64, 108, 235, 1);
        border-radius: 21upx;

        &:after {
            width: 50%;
        }
    }
}

.allOrder {
    width: 100%;
    height: 100%;
    padding: 24upx;
    margin-top: 70upx;
    box-sizing: border-box;

    .orderBox {
        // height: 370upx;
        background: #ffffff;
        margin-bottom: 24upx;
        border-radius: 10px;
        position: relative;

        .title {
            height: 72upx;
            padding-left: 24upx;
            padding-right: 24upx;
            box-sizing: border-box;
            font-size: 26upx;
            border-bottom: 1upx solid #eeeeee;
            display: flex;
            align-items: center;
            position: relative;

            .number {
                width: auto;
                height: 25upx;
                color: #333333;
                display: block;
                float: left;
            }

            .status {
                // width:78upx;
                height: 25upx;
                display: block;
                color: #f7b55f;
                position: absolute;
                right: 24upx;
            }
        }
    }
}

.image {
    image {
        width: 200upx;
        height: 200upx;
        position: absolute;
        right: -40upx;
        top: -40upx;
        z-index: 5;
        animation-name: mychange;
        animation-duration: 500ms;
    }
}

@keyframes mychange {
    0% {
        position: absolute;
        right: -20upx;
        top: -20upx;
        z-index: 5;
        transform: scale(1.3);
    }

    50% {
        position: absolute;
        right: -20upx;
        top: -20upx;
        z-index: 5;
        transform: scale(1.3);
    }

    100% {
        position: absolute;
        right: -40upx;
        top: -40upx;
        z-index: 5;
        transform: scale(1);
    }
}

.allOrder .orderBox .info {
    display: flex;
    padding: 8px 12px;
    flex-wrap: wrap;
    border-bottom: 1upx solid #eeeeee;

    .con {
        width: 50%;
        height: 45upx;
        line-height: 45upx;
        display: flex;
        align-items: center;

        .txt1 {
            position: relative;
            flex: 0 4rem;
            font-size: 24upx;
            color: #666666;
        }

        .txt1::after {
            position: absolute;
            content: ":";
            right: 8px;
        }

        .txt2 {
            flex: 1;
            font-size: 24upx;
            color: #666666;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    }
}

// 筛选框
.searchDrawer {
    margin: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: auto;
    z-index: 993;

}

.content {
    background: #f3f7fa;
    width: 100%;
    height: 100vh;
    overflow: hidden;

    .search_list {
        margin-top: 10upx;
        padding: 10px;

        .search_title {
            width: 100%;
            font-size: 26upx;
            color: #000;
            font-weight: 500;
            font-family: PingFang SC;
            padding: 20upx 24upx;
            box-sizing: border-box;
            display: block;
            font-weight: 600;

        }

        .search_type {
            box-sizing: border-box;
            display: flex;
            justify-content: left;
            flex-wrap: wrap;

            .view_box {
                width: 154upx;
                height: 66upx;
                display: flex;
                justify-content: center;
                align-items: center;

                margin-top: 16upx;
                margin-right: 16upx;
                font-size: 24upx;
                white-space: wrap;
                color: #666666;
                background: #f6f6f6;
                border-radius: 5px;
                border: 1upx solid #f6f6f6;

                text {
                    text-align: center;
                }
            }

            //选中状态
            .actived {
                background: #eef2ff !important;
                border: 1upx solid #406ceb;
                color: #406ceb !important;
            }
        }
    }

    .scroll_height {
        height: calc(100vh - 300px);
        overflow: auto;
    }
}

.btn {
    width: 100%;
    height: 73upx;
    position: absolute;
    bottom: 33upx;
    display: flex;
    justify-content: center;

    button {
        width: 214upx;
        height: 73upx;
        line-height: 73upx;
        font-size: 28upx;
        border-radius: 37px;
    }

    .reset {
        color: #406ceb;
        border: 1px solid rgba(64, 108, 235, 1);
        background: #ffffff;
    }

    .save {
        background: #406ceb;
        color: #ffffff;
    }
}
</style>
